Repository navigation
feat!: rename groups through Groups.Update - #155
Merged
Merged
Conversation
Groups.Update took the group's own name as the URL path, so it could not rename. It now takes the current name for the path and sends the new one as "groupname", the only key erchef reads it from (oc_chef_group:update_from_ejson). A differing name renames the group: erchef answers 201 with a Location (oc_chef_wm_base:update_from_json -> handle_rename) and echoes the PUT body. An empty Name and GroupName keep the current name; a Name and GroupName that disagree are refused. The caller's Group is not modified. cinc-server-ng stores a renaming group PUT under the old name, so groups/rename is a gap there, as clients/rename and users/rename are. BREAKING CHANGE: Groups.Update(ctx, g) is now Groups.Update(ctx, name, g). Signed-off-by: Tim Smith <tsmith84@proton.me>
A group read with Get carries its name in both Name and GroupName, so changing only one to rename it was refused as a disagreement. Update now takes the new name from whichever field differs from the current name, and refuses only two different new names. The rename gaps link cinc-server-ng#303. Signed-off-by: Tim Smith <tsmith84@proton.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Groups.Updateused the group's own name as the URL path, so it couldn't rename a group, although erchef supports renaming:oc_chef_group:update_from_ejsontakes the new name fromgroupname.oc_chef_wm_base:update_from_json→handle_renameanswers 201 withLocation.account_group_spec.rb:947-978): the old name 404s, the new one has the same members, and renaming onto an existing name is a 409.Updateis nowUpdate(ctx, name, g), likeClients.UpdateandUsers.Update:name, and the new name is sent asgroupname.g.Name/g.GroupNamediffers from the current name. A group read withGetcarries its name in both fields, so changing either one renames it.gisn't modified, and theactorsrewrapping is unchanged.AddMembers/RemoveMembersnever rename.name, soNameis filled fromGroupName.erchef doesn't protect the built-in groups (
admins,users,clients): an admin can rename them. That's server behavior, so the client doesn't add a guard.cinc-server-ng doesn't rename (cinc-project/cinc-server-ng#303), so
groups/renameis a gap there. The client and user rename gaps now link the same issue.Breaking:
Groups.Update(ctx, g)is nowGroups.Update(ctx, name, g).Test plan
groups/renamepasses against CINC Server 15.10.125 (erchef), together with every othergroups/*casego test ./... -race -count=2;groups.goat 100%cd integration && go test ./...(cinc-server-ng, with the gap); golangci-lint in both modules